<template>
  <a-card :bordered="false">
      <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <!-- <a-form-item label="申请人">
              <select-user-by-dep   :multi="false" v-model="queryParam.proposer" ></select-user-by-dep>
            </a-form-item> -->
            <a-form-item label="发生时间">
              <a-range-picker
              :allowClear="false"
              v-model="createTime"
              style="width: 100%"
              @change="createTimeChange"/>
              </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->
    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        :customRow="customRow"
        @change="handleTableChange">

      </a-table>
    </div>

  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import {DisabledAuthFilterMixin} from '@/mixins/DisabledAuthFilterMixin'
    import {getAction, httpAction} from '@/api/manage'

  export default {
    name: 'ErpOilTransactionDetailList',
    mixins:[JeecgListMixin, mixinDevice, DisabledAuthFilterMixin],
    components: {
    },
    data () {
      return {
        description: '油补交易明细表管理页面',
        //表头
        columns:[],
        //列设置
        settingColumns:[],
        createTime: [],
        queryParam:{},
        // 列定义
        defColumns: [
          {
            title: '序号',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'发生时间',
            align:"center",
            dataIndex: 'createTime',
          },
          {
            title:'充值金额',
            align:"center",
            dataIndex: 'payMoney',
          },
          {
            title:'提现金额',
            align:"center",
            dataIndex: 'withdrawMoney',
          }
          
        ],
        url: {
          list: "/api/erp/modules/workbench/oilSubsidy/erpOilTransactionDetail/list",
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    props: ['oilCardApplyUser'],
    created() {
      this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      createTimeChange(date, dateString) {
        this.$set(this.queryParam, 'createStartTime', dateString[0] + ' 00:00:00')
        this.$set(this.queryParam, 'createEndTime', dateString[1] + ' 23:59:59')
      },
      searchReset() {
        this.createTime = []
        this.queryParam = {}
        this.loadData(1)
    },
    customRow(record){},
      loadData(arg, userId) {
        if (!this.url.list) {
          this.$message.error('请设置url.list属性!')
          return
        }
        // 加载数据 若传入参数1则加载第一页的内容
        if (arg === 1) {
          this.ipagination.current = 1
        }
        this.params = this.getQueryParams() // 查询条件
        if(userId) {
          console.log('啦啦啦userId为：',userId);
          this.params.oilCardApplyUser = userId
          this.$set(this.queryParam,'oilCardApplyUser',userId)
        }
        this.loading = true
        this.params.oilCardApplyUser = this.oilCardApplyUser
        getAction(this.url.list, this.params).then(res => {
          if (res.success) {
            // console.log('result为：',res.result);
            // update-begin---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
            this.dataSource = res.result.records || res.result
            this.dataSource.forEach((item, index) => {
              item.key = index
            })
            if (res.result.total) {
              this.ipagination.total = res.result.total
            } else {
              this.ipagination.total = 0
            }
            //判断是否当前页没有数据且不为第一页
            if (this.dataSource.length == 0 && this.ipagination.current != 1) {
              this.ipagination.current = this.ipagination.current - 1
              this.loadData(this.ipagination.current - 1);
            }
            // update-end---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
          }
          if (res.code === 510) {
            this.$message.warning(res.message)
          }
          this.loading = false
        })
      },
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'BigDecimal',value:'payMoney',text:'充值金额',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'withdrawMoney',text:'提现金额',dictCode:''})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>
